package com.example.demo.proxy.start;

import com.example.demo.proxy.cglib.handler.CglibProxyHandler;
import com.example.demo.proxy.jdk.object.ProxyObject;
import com.example.demo.proxy.jdk.service.NumberOperationInterface;
import com.example.demo.proxy.jdk.service.StringOperationInterface;
import com.example.demo.proxy.jdk.service.impl.NumberOperationImpl;
import com.example.demo.proxy.jdk.service.impl.StringOperationImpl;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

@RunWith(JUnit4.class)
public class AppStart {

    @Test
    public void test(){
        NumberOperationInterface wrap = new ProxyObject().wrap(new NumberOperationImpl());
        int add = wrap.add(3, 4);
    }

    @Test
    public void sayHello(){
        StringOperationInterface wrap = new ProxyObject().wrap(new StringOperationImpl());
        String say = wrap.say();
    }


    @Test
    public void cglibProxy(){
        NumberOperationImpl instance = new CglibProxyHandler()
                .getInstance(new NumberOperationImpl());
        instance.add(3,4);
    }
}
